import request from '@/utils/request';

//文章创建
const create_article = ({title, category_id, head_img, content}) => {
    return request.post('posts', {title, category_id, head_img, content});
};

//获取文章详情
const get_article_detail = (id) => {
    return request.get('posts/' + id)
}

//获取全部文章列表
const get_pagelist = (path) => {
    return request.post(path)
}

//获取文章专栏列表
const get_article_column = (path) => {
    return request.post(path)
}

//我的文章列表获取
const get_my_articles = () => {
    return request.get('myArticles');
}

//文章修改
const update_article = (path,{title, category_id, head_img, content}) => {
    return request.put(path,{title, category_id, head_img, content});
}

//文章删除
const delete_article = (path) => {
    return request.delete(path);
}

//文章查询
const search_article = (title) =>{
    return request.post('search/' + title);
}


export default {
    create_article,
    get_article_detail,
    get_pagelist,
    get_article_column,
    get_my_articles,
    update_article,
    delete_article,
    search_article,
};